package lp.xian.equipment.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import lp.xian.equipment.vo.SalaryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lp.xian.equipment.mapper.SalaryMapper;
import lp.xian.equipment.domain.Salary;
import lp.xian.equipment.service.ISalaryService;

/**
 * 工资Service业务层处理
 *
 * @author ruoyi
 * @date 2023-07-21
 */
@Service
public class SalaryServiceImpl implements ISalaryService
{
    @Autowired
    private SalaryMapper salaryMapper;

    /**
     * 查询工资
     *
     * @param salaryId 工资主键
     * @return 工资
     */
    @Override
    public Salary selectSalaryBySalaryId(Integer salaryId)
    {
        return salaryMapper.selectSalaryBySalaryId(salaryId);
    }

    /**
     * 查询工资列表
     *
     * @param salary 工资
     * @return 工资
     */
    @Override
    public List<Salary> selectSalaryList(Salary salary)
    {
        return salaryMapper.selectSalaryList(salary);
    }

    /**
     * 新增工资
     *
     * @param salary 工资
     * @return 结果
     */
    @Override
    public int insertSalary(Salary salary)
    {
        salary.setCreateTime(DateUtils.getNowDate());
        return salaryMapper.insertSalary(salary);
    }

    /**
     * 修改工资
     *
     * @param salary 工资
     * @return 结果
     */
    @Override
    public int updateSalary(Salary salary)
    {
        salary.setUpdateTime(DateUtils.getNowDate());
        return salaryMapper.updateSalary(salary);
    }

    /**
     * 批量删除工资
     *
     * @param salaryIds 需要删除的工资主键
     * @return 结果
     */
    @Override
    public int deleteSalaryBySalaryIds(Integer[] salaryIds)
    {
        return salaryMapper.deleteSalaryBySalaryIds(salaryIds);
    }

    /**
     * 删除工资信息
     *
     * @param salaryId 工资主键
     * @return 结果
     */
    @Override
    public int deleteSalaryBySalaryId(Integer salaryId)
    {
        return salaryMapper.deleteSalaryBySalaryId(salaryId);
    }

    @Override
    public int auditSalary(SalaryVo salaryvo) {
        Salary salary=new Salary();
        salary.setSalaryId(salaryvo.getSalaryId());
        salary.setAuditStatus(1);
        salary.setAuditTime(new Date());
        salary.setAuditPerson(SecurityUtils.getUsername());
        return salaryMapper.updateSalary(salary);
    }
}
